package com.xmall.controller.wx;

import com.xmall.bean.vo.BaseRespVo;
import com.xmall.bean.vo.WxSearchIndexVo;
import com.xmall.service.WxSearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

//zp
@RestController
@RequestMapping("wx/search")
public class WxSearchController {

    @Autowired
    WxSearchService wxSearchService;

    @RequestMapping("index")
    public BaseRespVo wxSearchIndex (){
        WxSearchIndexVo wxSearchIndexVo = wxSearchService.wxSearchIndex();
        return BaseRespVo.ok(wxSearchIndexVo);
    }

    @PostMapping("clearhistory")
    public BaseRespVo wxClearHistory(){
        //todo
        //逻辑删除search_history表中user_id的数据
        wxSearchService.wxClearHistory();
        return BaseRespVo.ok();
    }
    @GetMapping("helper")
    public BaseRespVo wxSearchHelper(String keyword){
        //data返回的数据为list<String>
        //todo
        List<String> strings = wxSearchService.wxSearchHelper(keyword);
        return BaseRespVo.ok(strings);
    }

}
